﻿// -------------------------------------------------------------------------
//    @FileName         :    NFMMOSnsCommonPlugin.cpp
//    @Author           :    gaoyi
//    @Date             :    2025-03-26
//    @Email			:    445267987@qq.com
//    @Module           :    NFMMOSnsCommonPlugin
//
// -------------------------------------------------------------------------

#include "NFMMOSnsCommonPlugin.h"

#include <NFComm/NFObjCommon/NFTypeDefines.h>
#include "NFComm/NFPluginModule/NFIPluginManager.h"
#include "NFSnsCommonModule.h"
#include <NFSnsServer/NFSnsCommon/NFSnsRoleSimple.h>
#include <NFSnsServer/NFSnsCommon/NFTransBatchSimpleBase.h>
#include <NFSnsServer/NFSnsCommon/NFTransLoadRoleSimple.h>

#ifdef NF_DYNAMIC_PLUGIN

NF_EXPORT void DllStartPlugin(NFIPluginManager* pm)
{
    CREATE_PLUGIN(pm, NFMMOSnsCommonPlugin)

};

NF_EXPORT void DllStopPlugin(NFIPluginManager* pm)
{
    DESTROY_PLUGIN(pm, NFMMOSnsCommonPlugin)
};

#endif


//////////////////////////////////////////////////////////////////////////

int NFMMOSnsCommonPlugin::GetPluginVersion()
{
    return 0;
}

std::string NFMMOSnsCommonPlugin::GetPluginName()
{
    return GET_CLASS_NAME(NFMMOSnsCommonPlugin);
}

void NFMMOSnsCommonPlugin::Install()
{
    REGISTER_MODULE(m_pObjPluginManager, NFSnsCommonModule, NFSnsCommonModule);
}

void NFMMOSnsCommonPlugin::Uninstall()
{
    UNREGISTER_MODULE(m_pObjPluginManager, NFSnsCommonModule, NFSnsCommonModule);
}

bool NFMMOSnsCommonPlugin::InitShmObjectRegister()
{
    NFServerConfig* pConfig = FindModule<NFIConfigModule>()->GetAppConfig(NF_ST_SNS_SERVER);
    NF_ASSERT(pConfig);
    uint32_t maxOnlinePlayerNum = pConfig->GetMaxOnlinePlayerNum() * 1.2;
    /////////////////////////////////////////////////////////////////////////////////
    REGISTER_SHM_OBJ_WITH_HASH(NFSnsRoleSimple, maxOnlinePlayerNum*5);
    REGISTER_SHM_OBJ(NFTransLoadRoleSimple, maxOnlinePlayerNum*2);
    REGISTER_SHM_OBJ(NFTransBatchSimpleBase, 0);

    return true;
}
